﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using HelenServer.BugEngine.Contracts;
using Microsoft.EntityFrameworkCore;

namespace HelenServer.BugEngine.Dal;

[Table("Release")]
public partial class Release : IEqualityComparer<Release>
{
    [Key]
    public int Id { get; set; }

    [StringLength(64)]
    [Unicode(false)]
    public string Name { get; set; } = null!;

    public virtual Product Product { get; set; } = null!;

    [StringLength(256)]
    [Unicode(false)]
    public string Description { get; set; } = string.Empty;

    public DateTime CreatedDate { get; set; } = DateTime.Now;

    public ReleaseStatus Status { get; set; } = ReleaseStatus.Normal;

    public bool Deleted { get; set; } = false;

    public bool Equals(Release? x, Release? y)
    {
        return x is not null && y is not null &&
               x.Id == y.Id &&
               x.Name == y.Name &&
               EqualityComparer<Product>.Default.Equals(x.Product, y.Product) &&
               x.Description == y.Description &&
               x.CreatedDate == y.CreatedDate &&
               x.Status == y.Status &&
               x.Deleted == y.Deleted;
    }

    public int GetHashCode([DisallowNull] Release obj)
    {
        return HashCode.Combine(Id, Name, Product, Description, CreatedDate, Status, Deleted);
    }
}